<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/common/common.jsp" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加会员卡</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap 3.3.4 -->
    <link href="${ctx}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="${ctx}/static/plugins/layui/css/layui.css"  media="all">
    <!-- FontAwesome 4.3.0 -->
    <style type="text/css">
		.conetnt_div{
			width: 80%;
			margin-left: auto;
			margin-right: auto;
		}
		.conetnt_div table {
			width: 100%;
			height:200px;
			margin: 30px 0px 0px 0px;
		}
		.conetnt_div table td{
			height: 30px;
			line-height: 30px;
			padding: 0px 10px 0px 10px
		}
		.conetnt_div table tr{
			margin-top:20px;
		}
		.button_td{
			text-align: center;
		}
    </style>
</head>
<body>
<div class="wrapper">
	<div class = "conetnt_div">
		<table>
			<tr>
				<td>
					<label for="card_outerCode">选择文件：</label>
				</td>
				<td>
					<input type="text" class="form-control" id="file_url" readonly="readonly">
				</td>
				<td colspan="2">
					<input type="file" name="file" id="excelImport">
				</td>
			</tr>
		</table>
	</div>
</div>
<!-- jQuery 2.1.4 -->
<script src="${ctx}/static/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!--Bootstrap v3.3.4-->
<script src="${ctx}/static/plugins/layui/layui.js"></script>
<script>
var upload;
var layer;
$(function(){
	layui.use(['layer','upload'], function(){
		layer = layui.layer;
		upload = layui.upload;
		var url = '${ctx}/api/membercard/importMemberCard';
		var index;
		upload({
		    url: url,
		    elem : '#excelImport',
		    ext: 'xls|xlsx',
		    title :'导入会员卡excel',
		    type: 'file',
		    before : function(){
		    	$('#file_url').val($('#excelImport').val());
		    	index = layer.msg('导入中...',{time: 0});
		    },
		    success: function(data){ //上传成功后的回调
		    	if(data.code == 200){
		    		layer.close(index);
		    		layer.alert("成功导入：" + data.successNum + "条，失败 ：" + data.errorNum);
		    	}else{
		    		layer.msg(data.msg);
		    	}
	        }
	    });
	});
})


</script>
</body>
</html>